/*
 * Copyright 2011 group coding kata nantes
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package fr.coding.kata.nantes.roman.michel;

import fr.coding.kata.nantes.roman.commons.NumeralsToRomanInterface;
import org.apache.commons.lang.NotImplementedException;

class NumeralsToRoman implements NumeralsToRomanInterface {
	int numerals

	static LinkedHashMap numberToRomans = [
		1000: "M",
		500 : "D",
		100 : "C",
		50  : "L",
		10  : "X",
		9   : "IX",
		5   : "V",
		4   : "IV",
		1   : "I",
	]

	NumeralsToRomanInterface with(Integer numerals) {
		this.numerals = numerals
		this
	}

	String call() {
		def romans = ""
		numberToRomans.each {key, value ->
			while (numerals >= key) {
				romans += value
				numerals -= key
			}
		}
		romans
	}
	public static void main(String[] args) {
		new NumeralsToRoman().with(99).call()
	}
}
